import { InputQuestion, QuestionBase, TimeQuestion, SelectQuestion, RadioQuestion, TextQuestion, CustomTableQuestion, UploadQuestion } from '@/components/public-template';
import { TextTable } from '@/components/public-template';
import { TableBase } from '@/components/public-template';
import { regExp } from '@/utils/regExp';
import { Api } from '@/config/api/resourceFileInfo';

class HomeService {
  // 基础信息
  getQuestions() {
    const questions: QuestionBase<any>[] = [
      new TextQuestion({
        key: 'code',
        label: '单据编号',
        value: null
      }),
      new TextQuestion({
        key: 'creatorName',
        label: '创建人',
        value: null
      }),
      new TextQuestion({
        key: 'deptName',
        label: '创建部门',
        value: null
      }),
      new TextQuestion({
        key: 'remindDatetime',
        label: '到期提醒时间',
        value: null
      }),
      new TextQuestion({
        key: 'createdTime',
        label: '创建时间',
        value: null
      })
    ];
    return questions;
  }
  getQuestionsType() {
    // 申请类型
    const questions: QuestionBase<any>[] = [
      new SelectQuestion({
        key: 'status',
        label: '申请类型',
        value: '新建',
        type: 'dictionary',
        state: {
          filterName: 'DMS_PUBILC_FILE_APPLY_IS_TYPE'
        }
      })
    ];
    return questions;
  }
  getProposalQuestions() {
    const questions: QuestionBase<any>[] = [
      new RadioQuestion({
        key: 'applyResult',
        label: '意见',
        required: true,
        prompt: '请选择',
        value: 1,
        options: [
          {
            label: '通过',
            value: 1
          },
          {
            label: '驳回',
            value: 2
          }
        ]
      }),
      new InputQuestion({
        key: 'remark',
        label: '备注',
        type: 'textarea',
        reg: regExp.len100,
        prompt: '长度不可超过100个字符'
      }),
      new UploadQuestion({
        key: 'file',
        label: '上传附件',
        required: true,
        prompt: '请上传附件',
        value: null,
        state: {
          cancelLimit: true,
          previewFile: true,
          tipText: '附件大小不能超过50MB',
          tipClass: 'icon-help-circle',
          url: Api.resourceUploadFile,
          viewUrl: Api.getPreviewFileUrl,
          params: {},
          httpOpt: { timeout: 1000 * 60 * 3 },
          listType: 'text',
          fieldNames: {
            fileId: 'fileId',
            name: 'name',
            size: 'size',
            suffix: 'suffix'
          }
        }
      })
    ];
    return questions;
  }
}

export default new HomeService();
